package com.dextrys.testing.seleniumdemo.script;

import com.thoughtworks.selenium.*;
import org.junit.After;
import org.junit.Before;
import org.junit.Test;
import java.util.regex.Pattern;

public class MyTest extends SeleneseTestCase {
	@Before
	public void setUp() throws Exception {
		selenium = new DefaultSelenium("localhost", 4444, "*chrome", "http://ec2-50-17-66-243.compute-1.amazonaws.com:8080/centric/");
		selenium.start();
	}

	@Test
	public void testMy() throws Exception {
		selenium.chooseOkOnNextConfirmation();
		
		selenium.open("/centric/");
		selenium.type("username", "admin");
		selenium.type("password", "pass");
		selenium.click("action");
		selenium.waitForPageToLoad("30000");
		
		assertEquals("This application only permits a user to be logged in once\n and it appears that you are already logged in from\n the following internet address: 117.80.192.233.\n\n This message could also appear if you did not previously log out\n and you are simply trying to login again from the same browser.\n\n Choose OK to continue logging in.\n Choose CANCEL to return to the login screen.", selenium.getConfirmation());

		System.out.print(selenium.getAllWindowTitles());
		
		String title = selenium.getTitle();
		assertEquals("*My Home Page*", title);
		
//		selenium.click("link=Logout");
//		selenium.waitForPageToLoad("30000");
//		title = selenium.getTitle();
//		assertEquals("*Suite Community*", selenium.getTitle());
	}

	@After
	public void tearDown() throws Exception {
		selenium.stop();
	}
}
